package com.tsingteng.cosfun.utils;

import android.text.TextUtils;

import com.qiniu.pili.droid.shortvideo.PLShortVideoEditor;
import com.tsingteng.cosfun.helper.VideoHelper;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/10/9
 * qq(872179966)
 */

public class VideoFilterCommand extends Command {

    private final PLShortVideoEditor plShortVideoEditor;
    public int newIndex;
    public int oldIndex;
    public String oldFilterName;
    public String newFilterName;

    public VideoFilterCommand(PLShortVideoEditor plShortVideoEditor, int newIndex, int oldIndex, String newFilterName, String oldFilterName) {
        this.newIndex = newIndex;
        this.oldIndex = oldIndex;
        this.newFilterName = newFilterName;
        this.oldFilterName = oldFilterName;
        this.plShortVideoEditor = plShortVideoEditor;
    }


    @Override
    public boolean apply() {
        if (TextUtils.isEmpty(newFilterName)) return true;
        plShortVideoEditor.setBuiltinFilter(newFilterName);
        AppUtils.setBeautyFilterLevel(newIndex);
        return true;

    }

    @Override
    public boolean unapply() {
        AppUtils.setBeautyFilterLevel(oldIndex);
        if (TextUtils.isEmpty(oldFilterName))return true;
        plShortVideoEditor.setBuiltinFilter(oldFilterName);
        return true;
    }
}
